home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------------------------
- *
- * Simple Sample Application Framework
- *
- * ©1991 Apple Computer
- *
- -------------------------------------------------------------------------------------*/
- /*
- * windowstuff.c -- window class instantiation/dispatching
- *
- * change history:
- *
- * SJF 11/7/91 1.0d1 initial coding
- *
- */
-
- #include "const.h"
- #include "strconst.h"
- #include "mytypes.h"
- #include "mymenus.h"
- #include "globals.h"
- #include "utils.h"
- #include "windowstuff.h"
-
- #include "base.window.h"
-
-
- /* instantiate a new base window */
-
- WindowPtr BaseMakeWindow(Rect *wRect,StringPtr title,Boolean visible,short wdefProc,Boolean goAwayFlag)
- {
- TInfoHndl infoHndl;
- TInfoPtr infoPtr;
- WindowPtr theWindow;
- Str255 defaultTitle;
-
- if (title==nil) {
- pstrcpy(defaultTitle,kDefaultTitle);
- title = defaultTitle;
- }
-
- infoHndl = NewHandleChk(sizeof(TInfo));
- if (MemError()!=noErr)
- return nil;
-
- MoveHHi((Handle)infoHndl);
- HLock((Handle)infoHndl);
- infoPtr = *infoHndl;
-
- infoPtr->m_idle = BaseIdleWindow;
- infoPtr->m_fixCursor = BaseFixCursorWindow;
- infoPtr->m_activate = BaseActivateWindow;
- infoPtr->m_deactivate = BaseDeactivateWindow;
- infoPtr->m_update = BaseUpdateWindow;
- infoPtr->m_key = BaseKeyWindow;
- infoPtr->m_resize = BaseResizeWindow;
- infoPtr->m_click = BaseClickWindow;
- infoPtr->m_destroy = BaseDestroyWindow;
- infoPtr->m_undo = BaseUndoWindow;
- infoPtr->m_cut = BaseCutWindow;
- infoPtr->m_copy = BaseCopyWindow;
- infoPtr->m_paste = BasePasteWindow;
- infoPtr->m_clear = BaseClearWindow;
- infoPtr->m_print = BasePrintWindow;
- infoPtr->m_pageSetup = BasePageSetupWindow;
- infoPtr->m_save = BaseSaveWindow;
- infoPtr->m_load = BaseLoadWindow;
- infoPtr->m_event = BaseEventWindow;
-
- HUnlock((Handle)infoHndl);
-
- if (HasColorQD())
- theWindow = NewCWindow(nil,wRect,title,visible,wdefProc,(WindowPtr)-1L,goAwayFlag,(unsigned long)infoHndl);
-
- else
- theWindow = NewWindow(nil,wRect,title,visible,wdefProc,(WindowPtr)-1L,goAwayFlag,(unsigned long)infoHndl);
-
- ((WindowPeek)theWindow)->windowKind = kBaseWindow;
-
- infoPtr->window = theWindow;
- infoPtr->saved = false;
- infoPtr->changed = true;
-
- return theWindow;
- }
-
-
- void *BaseDestroyWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BaseIdleWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BaseFixCursorWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return;
- }
-
-
- void *BaseActivateWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- MenuHandle theMenu;
-
- theMenu = GetMHandle(kFileMenu);
- EnableItem(theMenu,kCloseItem);
-
- SetCursor(&qd.arrow);
- return nil;
- }
-
-
- void *BaseDeactivateWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- MenuHandle theMenu;
-
- theMenu = GetMHandle(kFileMenu);
- DisableItem(theMenu,kCloseItem);
-
- SetDefaultMenus();
- DrawMenuBar();
- return nil;
- }
-
-
- void *BaseUpdateWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BaseResizeWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- RgnHandle theRgn;
- Rect *oldSize;
-
- return nil;
- }
-
-
- void *BaseKeyWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BaseClickWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- info->changed = true;
- return nil;
- }
-
-
- void *BaseUndoWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BaseCutWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BaseCopyWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BasePasteWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BaseClearWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BasePrintWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BasePageSetupWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-
- void *BaseSaveWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- info->saved = true;
- info->changed = false;
-
- return nil;
- }
-
-
- void *BaseLoadWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- info->saved = true;
- info->changed = false;
-
- return nil;
- }
-
-
- void *BaseEventWindow(WindowPtr window,TInfoPtr info,void *data)
- {
- return nil;
- }
-
-